#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""验证第三题Excel输出文件"""

import pandas as pd
import os

def verify_excel_files():
    """验证生成的Excel文件质量"""
    
    # 检查第二题Excel文件
    print("=== 第二题Excel文件验证 ===")
    files_to_check_2 = [
        '第二题完整分析结果.xlsx',
        'result2_completed.xlsx'
    ]
    
    for filename in files_to_check_2:
        if os.path.exists(filename):
            try:
                xl = pd.ExcelFile(filename)
                print(f"✅ {filename}:")
                print(f"   📊 工作表数量: {len(xl.sheet_names)}")
                print(f"   📋 工作表名称: {xl.sheet_names}")
                
                # 检查每个工作表的数据量
                for sheet in xl.sheet_names:
                    df = pd.read_excel(filename, sheet_name=sheet)
                    print(f"   📈 {sheet}: {df.shape[0]}行 × {df.shape[1]}列")
                    
            except Exception as e:
                print(f"❌ {filename} 验证失败: {e}")
        else:
            print(f"❌ 文件不存在: {filename}")
    
    # 检查第三题Excel文件
    print("\n=== 第三题Excel文件验证 ===")
    files_to_check_3 = [
        '第三题_建模分析报告_20250815_101830.xlsx',
        'result3_completed.xlsx'
    ]
    
    for filename in files_to_check_3:
        if os.path.exists(filename):
            try:
                xl = pd.ExcelFile(filename)
                print(f"✅ {filename}:")
                print(f"   📊 工作表数量: {len(xl.sheet_names)}")
                print(f"   📋 工作表名称: {xl.sheet_names}")
                
                # 检查每个工作表的数据量
                for sheet in xl.sheet_names:
                    df = pd.read_excel(filename, sheet_name=sheet)
                    print(f"   📈 {sheet}: {df.shape[0]}行 × {df.shape[1]}列")
                    
            except Exception as e:
                print(f"❌ {filename} 验证失败: {e}")
        else:
            print(f"❌ 文件不存在: {filename}")

if __name__ == "__main__":
    verify_excel_files() 